package com.xoa.controller.inv;

import com.xoa.model.inv.ProductType;
import com.xoa.service.inv.ProductTypeService;
import com.xoa.util.ToJson;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 商品类管理
 */
@Controller
@RequestMapping("/productType")
public class ProductTypeController {

    @Resource
    private ProductTypeService productTypeService;

    /**
     * 新建商品类信息接口
     * @param request
     * @param productType
     * @return
     */
    @ResponseBody
    @RequestMapping("/insertProductType")
    public ToJson<ProductType> insertProductType(HttpServletRequest request, ProductType productType){
         return productTypeService.insertProductType(request,productType);
    }

    /**
     * 修改商品信息接口
     * @param request
     * @param productType
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateProductType")
    public ToJson<ProductType> updateProductType(HttpServletRequest request,ProductType productType){
        return productTypeService.updateProductType(request,productType);
    }

    /**
     * 查询商品详情信息
     * @param request
     * @param productTypeId
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectProductTypeById")
    public ToJson<ProductType> selectProductTypeById(HttpServletRequest request,Integer productTypeId){
        return productTypeService.selectProductTypeById(request,productTypeId);
    }


    /**
     * 删除商品信息
     * @param request
     * @param productTypeId
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteProductTypeById")
    public ToJson<ProductType> deleteProductTypeById(HttpServletRequest request,Integer productTypeId){
        return productTypeService.deleteProductTypeById(request,productTypeId);
    }

    /**
     * 列表查询商品类信息
     * @param request
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectProductTypeInfo")
    public ToJson<ProductType> selectProductTypeInfo(HttpServletRequest request){
        return productTypeService.selectProductTypeInfo(request);
    }

    /**
     * 条件查询仓库信息
     * @param request
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectProductTypeByName")
    public ToJson<ProductType> selectProductTypeByName(HttpServletRequest request,String productTypeName){
        return productTypeService.selectProductTypeByName(request,productTypeName);
    }

}
